package com.nate.tasking.actions;

import java.util.List;

import javax.jdo.PersistenceManager;

import org.apache.log4j.Logger;

import com.nate.tasking.data.PMF;
import com.nate.tasking.domain.Task;
import com.opensymphony.xwork2.ActionSupport;

public class ViewTasksAction extends ActionSupport{

	private static final long serialVersionUID = 6390974667995625397L;
	private final Logger logger = Logger.getLogger(ViewTasksAction.class);
	private List<Task> listOfTasks;

	public String execute(){
		logger.debug("View Tasks Action");
		
		PersistenceManager pm = PMF.get().getPersistenceManager();
    	try {
    		String query = "select from " + Task.class.getName();
    	    listOfTasks = (List<Task>) pm.newQuery(query).execute();
    	    System.out.println("user list size: " + listOfTasks.size());
            logger.debug("retrieved users");
        } finally {
            pm.close();
        }
		return SUCCESS;
	}

	public List<Task> getListOfTasks() {
		return listOfTasks;
	}

	public void setListOfTasks(List<Task> listOfTasks) {
		this.listOfTasks = listOfTasks;
	}
	
}
